﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Model;
using System.Data.SqlClient;

namespace BLL
{
    public class AuthorityAndRolesBLL
    {
        AuthorityAndRolesDAL dal = new AuthorityAndRolesDAL();

        /// <summary>
        /// 显示所有角色权限
        /// </summary>
        /// <returns></returns>
        public List<AuthorityAndRoles> ShowAuthorityAndRoles()
        {
            return dal.Show();
        }


        /// <summary>
        /// 根据条件查找角色权限信息
        /// </summary>
        /// <returns></returns>
        public List<AuthorityAndRoles> ShowAuthorityAndRoles(int roles_Id, int ParentId)
        {
            SqlParameter[] sp1 = new SqlParameter[]{
                  new SqlParameter("roles_Id",roles_Id),
                  new SqlParameter("ParentId",ParentId)
            };
            return dal.Show(sp1);
        }

        public List<AuthorityAndRoles> PaperAuthorityAndRoles(int PageIndex, int PageSize, out int PageCount)
        {
            PageCount = dal.Show().Count();
            return dal.Show().Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }
        /// <summary>
        /// 添加角色权限
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool AddAuthorityAndRoles(AuthorityAndRoles m)
        {
            return dal.Add(m);
        }
        /// <summary>
        /// 删除角色权限
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool DelAuthorityAndRoles(AuthorityAndRoles m)
        {
            return dal.Del(m);
        }

        /// <summary>
        /// 查询单个角色权限信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AuthorityAndRoles BackAuthorityAndRoles(int id)
        {
            return dal.Back(id);
        }

        /// <summary>
        /// 修改角色权限信息
        /// </summary>
        /// <param name="m"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdAuthorityAndRoles(AuthorityAndRoles m, int id)
        {
            return dal.Update(m, id);
        }
    }
}
